﻿using Microsoft.AspNetCore.Mvc;

namespace ProductService.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class ProductController : Controller
    {
        private readonly IConfiguration _configuration;
        public ProductController( IConfiguration configuration)
        {
            _configuration= configuration;  
        }

        private static List<ProductEntity> products = new List<ProductEntity>()
        {
            new ProductEntity(){Id=1, Name="拯救者Y9000k", Price=11999},
            new ProductEntity(){Id=2, Name="ThinkPad", Price=3499},
            new ProductEntity(){Id=3, Name="RedMi", Price=2299}
        };

        [HttpGet(nameof(Products))]
        public IActionResult Products()
        {
            Console.WriteLine($"{DateTime.Now} current Port:" + _configuration["port"]);
            return Ok(products);
        }
    }
    public class ProductEntity
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public int Price { get; set; }
    }
}
